import { KillEvilPropItem } from "./KillEvilPropItem";
import { Cache } from "../../cache/Cache";
import { ObjCreate } from "../common/ObjCreate";
import { ColorConfig } from "../../resource/ColorConfig";
import { Language } from "../../../../extend/language/Language";
import { DataEvent } from "../../events/DataEvent";
import { GModuleEvent } from "../../mvc/GModuleEvent";
import { EKillEvilType } from "../../../../Message/Game/EKillEvilType";
import { SMyKillEvilGetInfo } from "../../../../Message/Game/SMyKillEvilGetInfo";
import { GLabel } from "../../../../com/mui/controls/GLabel";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class KillEvilGetTaskItem
    
    export  class KillEvilGetTaskItem /* flash.display.Sprite */
    {
        constructor(arg1: int)
        {
            
            this._type = arg1;
            this.createChildren();
            return;
        }

        protected createChildren(): void
        {
            var loc1=new KillEvilPropItem(this._type);
            this.addChild(loc1);
            var loc2=Cache.instance.killEvilTask.getKillEvilTaskName(this._type);
            var loc3=Cache.instance.killEvilTask.getKillEvilTaskColor(this._type);
            ObjCreate.createLabel(loc2, -28, 75, 126, 20, flash.text.TextFormatAlign.CENTER, this, true, ColorConfig.instance.getItemColor(loc3).intColor);
            this._expLabel = ObjCreate.createLabel("", -28, 93, 126, 60, flash.text.TextFormatAlign.CENTER, this, false, 14724872);
            this._getTaskBtn = ObjCreate.createGButton(Language.getString(90157), -18, 151, 106, 26, this, "ButtonSpecial");
            this._quickCommitBtn = ObjCreate.createGButton(Language.getString(90158), -18, 151, 106, 26, this, "ButtonSpecial");
            this._getTaskBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onGetTaskBtnClick);
            this._quickCommitBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onQuickCommitClick);
            return;
        }

        /* internal  */onGetTaskBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.dispatchEvent(new DataEvent(GModuleEvent.KillEvilTaskGetTask, this._type, false, true, true));
            return;
        }

        /* internal  */onQuickCommitClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.dispatchEvent(new DataEvent(GModuleEvent.KillEvilTaskQuickCommit, null, false, true, true));
            return;
        }

        public updateCanGetInfo(): void
        {
            var loc3=0;
            var loc4=0;
            var loc5=false;
            var loc1=Cache.instance.killEvilTask.canGetInfo;
            var loc2=Cache.instance.killEvilTask.releaseInfo;
            var loc6=this._type;
            switch (loc6) 
            {
                case EKillEvilType._EKillEvilTypeHuman:
                {
                    loc3 = loc1.killEvilTypeHuman;
                    loc4 = loc2.expHuman;
                    loc5 = loc1.killEvilTypeHuman > 0;
                    break;
                }
                case EKillEvilType._EkillEvilTypeEarth:
                {
                    loc3 = loc1.killEvilTypeEarth;
                    loc4 = loc2.expEarth;
                    loc5 = loc1.killEvilTypeEarth > 0;
                    break;
                }
                case EKillEvilType._EkillEvilTypeHeaven:
                {
                    loc3 = loc1.killEvilTypeHeaven;
                    loc4 = loc2.expHeaven;
                    loc5 = loc1.killEvilTypeHeaven > 0;
                    break;
                }
                case EKillEvilType._EkillEvilTypeGod:
                {
                    loc3 = loc1.killEvilTypeGod;
                    loc4 = loc2.expGod;
                    loc5 = loc1.killEvilTypeGod > 0;
                    break;
                }
            }
            this._expLabel.htmlText = Language.getStringByParam(90159, loc3.toString(), loc4.toString());
            this._getTaskBtn.enabled = loc5;
            return;
        }

        public updateHadGetInfo(arg1: SMyKillEvilGetInfo, arg2: Boolean): void
        {
            if (arg1.executeKillEvilType != this._type) 
            {
                this._getTaskBtn.visible = true;
                this._quickCommitBtn.visible = false;
            }
            else if (arg2) 
            {
                this._getTaskBtn.visible = false;
                this._quickCommitBtn.visible = true;
            }
            else 
            {
                this._getTaskBtn.visible = true;
                this._quickCommitBtn.visible = false;
            }
            return;
        }

        /* internal */ /* var */_type: int;

        /* internal */ /* var */_expLabel: GLabel;

        /* internal */ /* var */_getTaskBtn: GButton;

        /* internal */ /* var */_quickCommitBtn: GButton;
    }
